Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for participant count #944

Open
wants to merge 1 commit into
base: 6.x
Choose a base branch
from

Conversation

MegaphoneJon
Copy link
Contributor

Overview

In event price sets, a price option can have a "participant count". E.g. purchasing a "table for 10" ticket will increment the participant count by 10 despite buying one ticket. This PR adds support for participant counts in WFC.

Before

All tickets purchased count as one participant.

After

A "participant count" field exists This can be a numeric input, Computed Twig, etc.

The "Fee Amount" is not affected by the count. If you want the fee amount to be "per participant", you'll use Twig.

Technical Details

Participant count requires a line item with a non-NULL price_field_value_id). WFC has line items for paid events only. We never populate price_field_value_id.

So:

  • We introduce a new field "Participant Count" (in AdminHelp.php and Fields.php).
  • We create a hidden price field exclusively for use by WFC events. The Utils.php function returns that price field value, and will create it if it doesn't exist.
  • When recording a contribution's line items, we now include the count. We make changes to qty and unit_price to be count-aware (if used). We include the required line_total and price_field_value_id so participant count is calculated correctly.
  • When recording events, we check if it's a paid event. If not, we create a line item tied to the participant record.

Comments

When testing, note that API4's "remaining participants" calculated field is inaccurate for multiple reasons. To view an accurate count, call Api3 event.get and return underdocumented value is_full (see screenshot).

Selection_2130

@MegaphoneJon
Copy link
Contributor Author

I'll address these failures tomorrow.

@MegaphoneJon
Copy link
Contributor Author

test this please

@KarinG
Copy link
Collaborator

KarinG commented Feb 15, 2024

I just kicked off the test by pushing a trivial commit to your participant-count-deux branch.

@MegaphoneJon MegaphoneJon force-pushed the participant-count-deux branch from 1037adf to 7ca57d9 Compare February 16, 2024 00:51
@MegaphoneJon
Copy link
Contributor Author

I'll resolve the conflict here soon. This should pass existing tests, but I have new tests that aren't all passing. Event line items have always been a little inconsistent in WFC and I need to figure out how consistent they need to be made to support this.

@KarinG
Copy link
Collaborator

KarinG commented Feb 16, 2024

Ah cool on the test! If needed we can bring this over the finish line in Montreal!

@MegaphoneJon MegaphoneJon force-pushed the participant-count-deux branch 6 times, most recently from bddbbf4 to ec465b4 Compare April 9, 2024 19:57
@MegaphoneJon
Copy link
Contributor Author

OK - this is now updated to create line items correctly in both "register all for same event" and "register each contact separately".

Previously - line items were created correctly only when "register each contact separately" was selected. When "register all for same event" was selected, one line item was created for the entire transaction. This threw off participant count calculations, which assume if there's a missing line item, the count is 1. So registering 3 people for 4 seats each would take up 14 places, not 12 (since contact 1 would have a line item for 12 places, contacts 2 and 3 would have no line items).

My latest changes ensure that separate line items are created for each participant record.

fix for participant count code
@MegaphoneJon MegaphoneJon force-pushed the participant-count-deux branch from ec465b4 to 20fa33d Compare April 9, 2024 21:38
return $qtyPriceFieldValueId;
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be moved to an upgrade hook?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants